#!/usr/bin/env bash

LOG=~/.scripts/logs/backup_moodle.log

now=`date +%Y%m%d_%H%M%S`
cd /media/OS/Backups/Moodle

echo "##############################################" >> $LOG
echo "`date` : Backing up database" >> $LOG
mysqldump -h localhost -u moodle --password=moodle -C -Q -e --create-options --skip-dump-date moodle > moodle_database_${now}.sql
gzip moodle_database_${now}.sql

echo "`date` : Backing up files" >> $LOG
rsync -auvtz --delete -e ssh /var/lib/moodle/ files/ >/dev/null 2>&1
